var library = [];

(function Creator (window) {
	
	Creator.library = [];

	Creator.create = function (_id,_class,_where,_content){
		
		var creation = {}
		
			creation.id = _id;
			creation.class = _class;
			creation.parent = _where;
	
		$(_where).append('<div id="' + _id + '" class="'+ _class + '" >' + _content + '</div>');
		console.info("created div id=", _id);
			if ($(_where) != []) {
			Creator.library.push(creation);

		}
		creation = null;
	}

	//get library of objects
	Creator.getLibrary = function () {
	
		return Creator.library;

	}
	
	//set content to object in library
	Creator.setContent = function (id,content) {
				
	console.log(Creator.getObjectById(id),"trace")
			if (Creator.getObjectById(id))	{
					$('#' + id).html(content);
					return false;
				} else  {
					
					alert ("null value")
				}
			
					
	}

	Creator.getObjectById = function (query) {
		
		if (Creator.library.length > 0) {

				for (var i=0; i<Creator.library.length;i++ )
					{
						if (query===Creator.library[i].id) {
							return Creator.library[i];
						} else {
							return null;
						}
					}
		}
	}
	
	
	

	window.Creator = Creator;

})(window);